<?php
/**
 * Created by PhpStorm.
 * User: kaycn
 * Date: 18-9-18
 * Time: 下午7:00
 */
namespace Pay;

class memcache{

    public $mem;

    public function __construct()
    {
        $this->mem = new \Memcache();

        if(!$this->mem->connect('localhost', 11211)){

            echo "连接错误";

            return false;

        }


    }

    public function sava($data){

       if( count($data) == count($data, 1)){

           foreach ($data as $key=>$val){

               $this->mem->set($key,$val,0,0);

           }
       }else{
           $data = array_shift($data);

           foreach ($data as $key=>$val){

               $this->mem->set($key,$val,0,0);

           }

       }



    }

    public function get($key){

        return $this->mem->get($key);
    }


}